package whyusethem;

import java.util.LinkedList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: gia
 * Date: 29.08.2012
 * Time: 21:46
 *
 */
public class UsingRawTypesBlah {

    public static void main(String[] args) {
        /* a list of Integers */
        List luckyNumbers = getMyLuckyNumbers();

        System.out.println(sumLuckyNumbers(luckyNumbers));

    }

    private static int sumLuckyNumbers(List luckyNumbers) {
        int sum = 0;

        for (Object luckyNumber : luckyNumbers) {
            sum += (Integer) luckyNumber;
        }

        return sum;
    }


    private static List getMyLuckyNumbers() {

        List luckyNumbers = new LinkedList();
        luckyNumbers.add(4);
        luckyNumbers.add(6);
        luckyNumbers.add(13);

        return luckyNumbers;

    }

    static void rawTypesGoodUsageScenario(Object o){

        if(o instanceof Iterable){
            Iterable<?> comparableObject = (Iterable<?>) o;
            System.out.println(comparableObject.iterator().hasNext());
        }

        Class<Comparable> comparableClass = Comparable.class;

    }


}
